<template>
    <div>
        {{msg}}
        用户名：<input type="text" v-model="username"><br>
        密码：<input type="text" v-model="psd"><br>
        <input type="submit"  value="登录" @click="login">
    </div>
</template>

<script>
export default {
    data() {
        return {
            msg:"我是登录界面",
            username:"",
            psd:""
        };
    },
    created() {
        // 一进入登陆页面的时候先清空我们本地存贮的数据
         localStorage.removeItem("obj");
    },
    methods: {
        login(){
            var obj={
                name:this.username,
                psd:this.psd
            }
        if(!this.username ||  !this.psd){
           alert("请输入")
        }else{
            localStorage.setItem("obj",JSON.stringify(obj))
            this.$router.push('/home')
        }

        }

    },
    components: {

    },
};
</script>

<style>

</style>
